package com.mikey.springcloud.service;

import com.mikey.springcloud.pojo.Category;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author :Mikey
 * @description :
 * @create :2022-09-05 16:35:00
 */
@Component
public class CategoryFailBackFactory implements FallbackFactory {
    public CategoryClientService create(Throwable throwable) {
        return new CategoryClientService() {
            public List<Category> list() {
                return null;
            }

            public Category findOne(Integer id) {
                Category category = new Category();
                category.setId(id);
                category.setName("服务降级");
                return category;
            }
        };
    }
}
